home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZDLTSTR.C < prev    next >
Text File  |  1988-12-18  |  2KB  |  40 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │jzdltstr                                                                    │
  4. │Delete fnum chars from string fdestin starting at fstart.                   │
  5. │Returns number of characters deleted.                                       │
  6. │Synopsis:                                                                   │
  7. │  *s = "this is a test";                                                    │
  8. │  jzdltstr(s,5,3);                                                          │
  9. │  { results in "this a test" }                                              │
  10. │                                                                            │
  11. │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950                      │
  12. └────────────────────────────────────────────────────────────────────────────┘
  13. */
  14. #include <jaz.h>
  15.  
  16. jzdltstr(fdestin,fstart,fnum)
  17. char *fdestin;
  18. int fstart;
  19. int fnum;
  20. {
  21.  
  22.   int wdlen;                    /* hold length of destination string */
  23.   char *p;                      /* temporary pointer to fstart+fnum  */
  24.   int w;                        /* string counter */
  25.  
  26.   /* fstart is greater than string length */
  27.   if (((wdlen = strlen(fdestin)) < fstart))
  28.     return(0);
  29.  
  30.   fnum = min(fnum,wdlen-fstart);        /* don't delete past end of string */
  31.   p = fdestin + fstart + fnum;          /* point to part of string to move */
  32.   fdestin += fstart;                    /* point to part of string to delete*/
  33.  
  34.   for (w = 0 ; *fdestin++ = *p++ ; w ++)
  35.      ;
  36.  
  37.   return(w);
  38. }
  39.  
  40.